package com.example.kafkademo.interceptor;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author yanyun zhu
 * @version 1.0
 * @date 2021/12/28 16:21
 */
public class AvgLatencyProducerInterceptor implements ProducerInterceptor<String, String> {


    private RedisProperties.Jedis jedis; // 省略 Jedis 初始化
    private static Map map = new ConcurrentHashMap();


    @Override
    public ProducerRecord<String, String> onSend(ProducerRecord<String, String> record) {
        System.out.println("onSend");
//        jedis.incr("totalSentMessage");
        return record;
    }


    @Override
    public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
        System.out.println("onAcknowledgement");
    }


    @Override
    public void close() {
    }


    @Override
    public void configure(Map<String, ?> configs) {
    }
}